from sympy import Symbol, Piecewise, sin, limit

if __name__ == '__main__':
    x = Symbol("x")

    expression = Piecewise(
        (x + 1, x <=0),
        (sin(x)/x, x >0 )
    )

    # 计算函数的左极限和右极限
    limit_left = limit(expression, x, 0, dir="-")
    limit_right = limit(expression, x, 0, dir="+")

    print("limit_left = ", limit_left)
    print("limit_right = ", limit_right)

    expression_value = expression.subs(x, 0)
    print("expression_value = ", expression_value)

    if limit_left == limit_right == expression_value:
        print("函数连续")





